package userserv

import (
	"fmt"
	"net/http"
	"strings"
)

func replyError(w http.ResponseWriter, ec int) {
	w.Header().Set("error", fmt.Sprintf("%d", ec))
	w.Write(nil)
}

func commaString2Array(src string) []string {
	if src == "" {
		return []string{}
	}

	var result []string
	if strings.Contains(src, ",") {
		result = strings.Split(src, ",")
	} else {
		result = []string{src}
	}

	return result
}

func commaStringContain(src string, substr string) bool {
	result := commaString2Array(src)
	for _, a := range result {
		if a == substr {
			return true
		}
	}
	return false
}
